package foodmaterial.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import foodmaterial.utils.Constants;
import org.hibernate.validator.constraints.Range;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.Pattern;
import java.io.Serializable;
import java.util.Date;

public class CompanyDatabase implements Serializable {

    private static final long serialVersionUID = -6430449166705263625L;

    @JsonSerialize(using= ToStringSerializer.class)
    private  Long    id ;
    @NotEmpty(message = "公司名称不能为空")
    private  String  name;  //公司名称
    @NotEmpty(message = "数据库名称不能为空")
    @Pattern(regexp = "^[a-z0-9A-Z]+$",message = "数据库名只能出现数字和字母")
    private  String database ; //公司对应的数据库名称
    @Pattern(regexp = "([1-9]|[1-9]\\\\d|1\\\\d{2}|2[0-4]\\\\d|25[0-5])(\\\\.(\\\\d|[1-9]\\\\d|1\\\\d{2}|2[0-4]\\\\d|25[0-5])){3}",message = "数据库名只能出现数字和字母")
    private  String ip = "127.0.0.1";  //default '127.0.0.1'
    @Min(value = 1000,message = "端口号必须大于等于1000")
    private  Integer port = 3306; //default 3306,
    @Range(min = 1,max = 10 ,message = "连接池支持的最大连接数范围在【1-10】")
    private  Integer maxActive = 10;  //default 10, #连接池支持的最大连接数
    private  Integer maxIdle = 1; //default 1, # 连接池中最多可空闲maxIdle个连接
    private  Integer minIdle = 1; //default 1, # 连接池中最小空闲连接数
    @Range(min = 1,max = 10 ,message = "连接池初始化连接数目范围在【1-10】")
    private  Integer initialSize = 3; //default 3 , #初始化连接数目
    @Range(min = 10000,max = 100000 ,message = "连接超时范围在【10000-100000】")
    private  Integer maxWait = 60000 ;  //default 60000, #连接池中连接用完时,新的请求等待时间,毫秒
    private  String driverName ;
    private  String username ;
    private  String password ;
    private  Boolean enabled ;
    @JsonFormat(pattern= Constants.DEFAULT_DATE_FORMAT,timezone="GMT+8")
    private Date termOfValidity ;

    private String foodSupplyType ;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDatabase() {
        return database;
    }

    public void setDatabase(String database) {
        this.database = database;
    }

    public String getIp() {
        return ip;
    }

    public void setIp(String ip) {
        this.ip = ip;
    }

    public Integer getPort() {
        return port;
    }

    public void setPort(Integer port) {
        this.port = port;
    }

    public Integer getMaxActive() {
        return maxActive;
    }

    public void setMaxActive(Integer maxActive) {
        this.maxActive = maxActive;
    }

    public Integer getMaxIdle() {
        return maxIdle;
    }

    public void setMaxIdle(Integer maxIdle) {
        this.maxIdle = maxIdle;
    }

    public Integer getMinIdle() {
        return minIdle;
    }

    public void setMinIdle(Integer minIdle) {
        this.minIdle = minIdle;
    }

    public Integer getInitialSize() {
        return initialSize;
    }

    public void setInitialSize(Integer initialSize) {
        this.initialSize = initialSize;
    }

    public Integer getMaxWait() {
        return maxWait;
    }

    public void setMaxWait(Integer maxWait) {
        this.maxWait = maxWait;
    }

    public String getDriverName() {
        return driverName;
    }

    public void setDriverName(String driverName) {
        this.driverName = driverName;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public Boolean getEnabled() {
        return enabled;
    }

    public void setEnabled(Boolean enabled) {
        this.enabled = enabled;
    }

    public Date getTermOfValidity() {
        return termOfValidity;
    }

    public void setTermOfValidity(Date termOfValidity) {
        this.termOfValidity = termOfValidity;
    }

    public String getFoodSupplyType() {
        return foodSupplyType;
    }

    public void setFoodSupplyType(String foodSupplyType) {
        this.foodSupplyType = foodSupplyType;
    }
}
